<template>
	<a-modal title="选择发货人" :centered="true" :footer="null" :maskClosable="false" :width=900 v-model="show" @ok="handleOk">
		<a-table :columns="columns" :dataSource="data" :pagination="pagination" :loading="loading" @change="handleTableChange">
			<a slot="name" slot-scope="text" href="javascript:;">{{text}}</a>
			<span slot="customTitle">姓名</span>
			<span slot="tags" slot-scope="tags">
		      <a-tag v-for="tag in tags" color="blue" :key="tag">{{tag}}</a-tag>
		    </span>
			<span slot="action" slot-scope="text, record">
		      <a href="javascript:;" @click="Choice(record)">选择</a>
		    </span>
		</a-table>
	</a-modal>
</template>

<script>
	import { mapState } from 'vuex'
	const columns = [{
			dataIndex: 'name',
			key: 'name',
			slots: {
				title: 'customTitle'
			},
			scopedSlots: {
				customRender: 'name'
			},
		},
		//{
		//title: '年龄',
		//dataIndex: 'age',
		//key: 'age',
		//},
		{
			title: '电话',
			dataIndex: 'Telephone',
			key: 'Telephone',
		},
		
		//{
		//title: '标签',
		//key: 'tags',
		//dataIndex: 'tags',
		//scopedSlots: { customRender: 'tags' },
		//}, 
		{
			title: '操作',
			key: 'action',
			scopedSlots: {
				customRender: 'action'
			},
		}
	];

//	const data = [{
//		key: '1',
//		name: 'John Brown',
//		age: 32,
//		Telephone: '13836554654',
//		tags: ['nice', 'developer'],
//	}, {
//		key: '2',
//		name: 'Jim Green',
//		age: 42,
//		Telephone: '15796546552',
//		tags: ['loser'],
//	}, {
//		key: '3',
//		name: 'Joe Black',
//		age: 32,
//		Telephone: '17655684564',
//		tags: ['cool', 'teacher'],
//	}];
	export default {
		data() {
			return {
				type:'',
				data:[],
				columns,
				show: false,
				loading: false,
				pagination: {
					pageSizeOptions: ['10', '20', '30', '40', '100'],
					defaultCurrent: 1,
					defaultPageSize: 10,
					showSizeChanger: true,
					showTotal: (total, range) => `共 ${total} 条记录`
				},
			}
		},
		computed: {},
		created: function() {},
		methods: {
			// 获取联系人信息
			getPersonndlList(type) {
				this.loading = true
				var params = {}
				params.pageSize = this.pagination.defaultPageSize
				params.pageNum = this.pagination.defaultCurrent
				params.type = type
				params.userId = this.user.userId
				this.$get('/info/infoLinkman', params).then((r) => {
					console.log('联系人信息：', r)
					let d = r.data.data.rows
					this.data = []
					if(type == 1){
						for(var i in d){
							this.data.push({
								name:d[i].receivePersion,
								Telephone:d[i].receivePersonMobile,
								id:d[i].linkmanId
							})
						}
					}else{
						for(var i in d){
							this.data.push({
								name:d[i].sendPerson,
								Telephone:d[i].sendPersonMobile,
								id:d[i].linkmanId
							})
						}
					}
					this.loading = false
				}).catch((e)=>{
					console.log(e)
					this.loading = false
				})
			},
			// 表格排序 分页 筛选事件
			handleTableChange(pagination, filters, sorter) {
				// this.getcarSource({
				//   ...this.queryParams
				// })
			},
			// 选择传值
			Choice(data) {
				this.$emit('PersonnelData', data ,this.type);
				this.show = false
			},
			// 获取type 查询列表  
    		// type = 0  发货人
    		// type = 1  收货人
			openDialog(type) {
				console.log(type)
				this.type = type
				this.getPersonndlList(type)
				this.show = true
			},
			handleOk(d) {
				this.$emit('change')
			},

		},
		computed: {
			...mapState({
				multipage: state => state.setting.multipage,
				user: state => state.account.user,
			}),
		},
	}
</script>
<style lang="less">
</style>